#include "stdio.h"
#include "stdlib.h"

#pragma region 基础结构
typedef struct charNode
{
    char data;
    struct charNode *next;
} CharStackNode, *CharLinkStack;
#pragma endregion

#pragma region 【算法2 - 23】判栈空算法
int Empty_CharLinkStack(CharLinkStack top)
{
    if (top == NULL)
        return 1;
    else
        return 0;
}
#pragma endregion

#pragma region 【算法2 - 24】入栈算法
CharLinkStack Push_CharLinkStack(CharLinkStack top, char x)
{
    CharStackNode *p;
    p = (CharStackNode *)malloc(sizeof(CharStackNode));
    p->data = x;
    p->next = top;
    top = p;
    return top;
}
#pragma endregion
#pragma region 【算法2 - 25】出栈算法
CharLinkStack Pop_CharLinkStack(CharLinkStack top, char *x)
{
    CharStackNode *p;
    if (top == NULL)
        return NULL;
    else
    {
        *x = top->data;
        p = top;
        top = top->next;
        free(p);
        return top;
    }
}
#pragma endregion
